/*
 * @Author: yovi
 * @Date: 2019-11-19 23:21:13
 * @LastEditTime: 2019-11-22 17:05:19
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \YouYouFo\you-you-go\src\api\index.js
 */
import Vue from 'vue'
import axios from 'axios'
Vue.prototype.$http = axios

axios.defaults.baseURL = "http://www.liulongbin.top:3005/"

/**
 * @name: getSwiper
 * @msg:获取轮播图 
 * @param:
 * @return: 
 */
export const getSwiper = () => {
  return axios.get('/api/getlunbo')
}

/**
 * @name: getNewsList
 * @msg: 获取新闻列表数据
 * @param: 
 * @return: [Json] 
 */
export const getNewsList = () => {
  return axios.get('/api/getnewslist')
}

/**
 * @name: getNewsDetail
 * @msg: 获取新闻详情数据
 * @param : newid [Number]
 * @return: [Json]
 */
export const getNewsDetail = (newsid) => {
  return axios.get(`/api/getnew/${newsid}`)
}

/**
 * @name: getImages
 * @msg: 获取图片列表数据
 * @param: cateid [Number]
 * @return: [Json]
 */
export const getImages = (cateid) => {
  return axios.get(`/api/getimages/${cateid}`)
}

/**
 * @name: getImageCategory
 * @msg: 用于获取图片列表页面上面的分类信息获取 
 * @param: none
 * @return: [Json]
 */
export const getImageCategory = () => {
  return axios.get('/api/getimgcategory')
}

/**
 * @name: getthumimages
 * @msg: 用于获取图片详情页面上部的图片列表数据
 * @param: imgid [Number]
 * @return: [Json] 
 */
export const getthumimages = (imgid) => {
  return axios.get(`/api/getthumimages/${imgid}`)
}

/**
 * @name: getimageInfo
 * @msg: 用于获取图片详情页面中的详细描述信息
 * @param: imgid [Number]
 * @return: [Json]
 */
export const getimageInfo = (imgid) => {
  return axios.get(`/api/getimageInfo/${imgid}`)
}

/**
 * @name: getcomments 
 * @msg: 根据资讯id获取它的评论的分页信息
 * @param: artid [Number]
 * @param: pageindex [Number]
 * @return: [Json]
 */
export const getcomments = (artid, pageindex) => {
  return axios.get(`/api/getcomments/${artid}?pageindex=${pageindex}`)
}

/**
 * @name: postcomment 
 * @msg: 给某条资讯进行评论
 * @param: artid [Number]
 * @param: content [String]
 * @return: [Json]
 */
export const postcomment = (artid, content) => {
  return axios.post(`/api/postcomment/${artid}`, {
    content
  })
}

/**
 * @name: getgoods 
 * @msg: 获取商品列表展示页面中的所有数据
 * @param: pageindex [Number]
 * @return: [Json]
 */
export const getgoods = (pageindex) => {
  return axios.get(`/api/getgoods?pageindex=${pageindex}`)
}

/**
 * @name: getgoodsDetail
 * @msg: 获取商品的图文介绍数据
 * @param: id [Number]
 * @return: [Json]
 */
export const getgoodsDetail = (id) => {
  return axios.get(`/api/goods/getdesc/${id}`)
}

/**
 * @name: getshopcarlist
 * @msg: 获取购物车列表数据
 * @param: idString [String] 商品id 字符串，多个id之间用逗号分隔
 * @return: [Json]
 */
export const getshopcarlist = (idString) => {
  return axios.get(`/api/goods/getshopcarlist/${idString}`)
}

/**
 * @name: getinfo
 * @msg: 获取商品参数区和价格，标题等数据
 * @param: id [Number] 商品主键值 
 * @return: [Json]
 */
export const getinfo = (id) => {
  return axios.get(`/api/goods/getinfo/${id}`)
}


/**
 * @name: getprodlist
 * @msg: 获取品牌数据json数据
 * @param: none 
 * @return: [Json]
 */
export const getprodlist = () => {
  return axios.get(`/api/getprodlist`)
}

/**
 * @name: delproduct
 * @msg: 删除搜索品牌数据
 * @param: id [Number] 传入品牌数据id
 * @return: [Json]
 */
export const delproduct = (id) => {
  return axios.get(`/api/delproduct/${id}`)
}

/**
 * @name: addproduct 
 * @msg: 添加搜索数据
 * @param: none
 * @return: [json]
 */
export const addproduct = (name) => {
  return axios.post(`/api/addproduct`, {
    name
  })
}

//获取图片详情轮播图信息
export var GetImg_api = (id) => {
  return axios.get(`/api/getthumimages/${id}`)
}
//获取商品列表信息
export var GoodsList = () => {
  return axios.get(`/api/getgoods?pageindex=1`)
}

//获取商品参数，价格，标题等信息
export var GoodsLnformation_api = (id) => {
  return axios.get(`/api/goods/getinfo/${id}`)
}

//获取购物车列表信息
export var getshopcarlist_api = (id) => {
  return axios.get(`/api/goods/getshopcarlist/${id}`)
}
